# 实现功能为：随便玩游戏几局，不想玩了，给出最终比赛结果
n = 0   # 统计胜利局数
m = 0   # 统计失败局数
i = 0
while i == 0:
    num = int(input('请输入你出的代码（石头：0、剪刀：1、布：2、不想玩：3)    '))
    if num == 3:
        break
    elif num in (0,1,2):        # 修补bug：输入其他数字会报错
        import random
        com_num = random.randint(0, 2)
        if num == com_num:
            print('a dead heat')  # 平局
        else:
            if num == 0 and com_num == 1:
                print('you win')
                n = n + 1
            elif num == 1 and com_num == 2:
                print('you win')
                n = n + 1
            elif num == 2 and com_num == 0:
                print('you win')
                n = n + 1
            else:
                print('you lose')
                m = m + 1
    else:
        print('error')
# 作比较，输出最总结果
if n > m:
    print(f'you win the game. win:{n},lose:{m}')
elif n < m:
    print(f'you lose the game. win:{n},lose:{m}')
else:
    print(f'a dead heat finally. win:{n},lose:{m}')
